package org.lingshi.utils;

import lombok.Getter;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.UUID;

public class FileUploader  {
    private MultipartFile mFile;
    private String dir;
    @Getter
    private String fileName;
    public FileUploader(MultipartFile mFile, String dir){
        this.mFile = mFile;
        this.dir = dir;
    }
	
    public FileUploader(MultipartFile mFile, String dir, boolean ran){
        /*-- 填入代码 --*/
    }

    private String uuid(){
        String id = UUID.randomUUID().toString();
        return id.replace("-","").substring(0,16);
    }

    public void transferTo(String fileName)
        throws IOException {
        File file = new File(dir + fileName);
        mFile.transferTo( file );
    }

    public void writeFile() throws IOException {
        transferTo( this.fileName );
    }

}
